import 'package:flutter_chat_ui/models/chat_opening_remarks_model.dart';

///
/// 自定义聊天信息模型
///
class ChatMessageData {
  /// 消息event
  String event;

  /// 咨询内容
  String query;

  /// 会话 ID，需要基于之前的聊天记录继续对话，必须传之前消息的 conversation_id
  String conversationId;

  /// 消息 ID
  String messageId;

  /// 消息创建时间
  int createdAt;

  /// 任务 ID
  String taskId;

  /// ID
  String id;

  /// 机器人是否正在加载
  bool isRobotLoading;

  /// 机器人响应文本
  String robotResponseText;

  /// 消息文件
  List<MessageFilesData> messageFiles;

  /// 反馈信息
  FeedbackData? feedbackData;

  /// 开场白【欢迎语】模型
  OpeningRemarksData? openingRemarksData;

  /// 推荐问题列表
  List<String> suggestedQuestions = [];

  ChatMessageData({
    required this.event,
    this.query = '',
    this.conversationId = '',
    this.messageId = '',
    this.createdAt = 0,
    this.taskId = '',
    this.id = '',
    this.isRobotLoading = false,
    this.robotResponseText = '',
    this.feedbackData,
    this.messageFiles = const [],
    this.openingRemarksData,
    this.suggestedQuestions = const [],
  });
}

///
/// feedback 模型 【反馈】
///
class FeedbackData {
  final String? rating;

  const FeedbackData({
    this.rating,
  });

  factory FeedbackData.fromJson(Map<String, dynamic> json) {
    return FeedbackData(
      rating: json['rating'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'rating': rating,
    };
  }
}

///
/// 消息文件模型
///
class MessageFilesData {
  final String? id;
  final String? type;
  final String? url;
  final String? belongsTo;

  MessageFilesData({
    this.id,
    this.type,
    this.url,
    this.belongsTo,
  });

  factory MessageFilesData.fromJson(Map<String, dynamic> json) => MessageFilesData(
        id: json["id"],
        type: json["type"],
        url: json["url"],
        belongsTo: json["belongs_to"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "type": type,
        "url": url,
        "belongs_to": belongsTo,
      };
}
